<?php
		include "pdfcrowd.php";
		$client = new Pdfcrowd("trantung8111", "970c8ea4ac0e157e01a8a316c8ac7698");
		if($_GET["cat"] == "hoso")
		{
			$link = 'http://localhost/luanvan/'.$_GET["url"]."?hosoid=".$_GET["hosoid"];
			$f = fopen($link, "rb");
			$contents = '';
			while (!feof($f)) {
			$contents .= fread($f, 8192);
			}
			fclose($f);
		}
		elseif($_GET["cat"] == "thongke")
		{
			if($_GET["loai"] == "tatca")
			{
				$link = 'http://localhost/luanvan/admin/'.$_GET["url"]."?loai=".$_GET["loai"];
				$f = fopen($link, "rb");
				$contents = '';
				while (!feof($f)) {
				$contents .= fread($f, 8192);
				}
				fclose($f);
			}
			elseif($_GET["loai"] == "theokhoi")
			{
				$link = 'http://localhost/luanvan/admin/'.$_GET["url"]."?loai=".$_GET["loai"]."&khoi=".$_GET["khoi"]."&tenkhoi=".$_GET["tenkhoi"];
				$f = fopen($link, "rb");
				$contents = '';
				while (!feof($f)) {
				$contents .= fread($f, 8192);
				}
				fclose($f);
			}
			elseif($_GET["loai"] == "saisot")
			{
				$link = 'http://localhost/luanvan/admin/'.$_GET["url"]."?loai=".$_GET["loai"];
				$f = fopen($link, "rb");
				$contents = '';
				while (!feof($f)) {
				$contents .= fread($f, 8192);
				}
				fclose($f);
			}
		}
		$pdf = $client->convertHtml($contents);
		ob_start();
		header("Content-Type: application/pdf");
		header("Accept-Ranges: none");
		header("Content-Disposition: attachment; filename=\"".$_GET["filename"].".pdf\"");
		ob_end_flush();
		echo $pdf;
?>